<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
          name="viewport"/>
    <link href="../ladmin/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
    <link href="../ladmin/css/font.css" rel="stylesheet">
    <link href="../ladmin/css/xadmin.css" rel="stylesheet">
    <script src="../ladmin/js/jquery.min.js"></script>
    <script src="../ladmin/lib/layui/layui.js"></script>
    <script src="../ladmin/js/xadmin.js" type="text/javascript"></script>
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <link href="../ladmin/lib/layui/css/modules/layer/default/layer.css" rel="stylesheet" type="text/css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="form-wrap">


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-card">
            <div class="layui-card-header">个人信息</div>
            <div class="layui-card-body">
                <form action="" class="layui-form" lay-filter="component-form-element">
                    <div class="layui-row layui-col-space10 layui-form-item">
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">成员学号：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" disabled="disabled" id="id"
                                       lay-verify="required" name="id" placeholder="" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">成员姓名：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" disabled="disabled" id="name"
                                       lay-verify="required" name="name" placeholder="" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">成员班级：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" id="class" lay-verify="required"
                                       name="class" placeholder="" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">联系方式：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" id="phone" lay-verify="required"
                                       name="phone" placeholder="" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">QQ：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" id="QQ" lay-verify="required" name="QQ"
                                       placeholder="" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">WeChat：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" id="WeChat" lay-verify="required"
                                       name="WeChat" placeholder="" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">Email：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" id="email" lay-verify="required"
                                       name="email" placeholder="" type="email">
                            </div>
                        </div>
                        <div class="layui-col-lg6">
                            <label class="layui-form-label">出生日期</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="birthday" placeholder="yyyy-MM-dd" type="text">
                            </div>
                        </div>
                        <div class="layui-col-lg12">
                            <label class="layui-form-label">成员宿舍：</label>
                            <div class="layui-input-block">
                                <input autocomplete="off" class="layui-input" id="address" lay-verify="required"
                                       name="address" placeholder="" type="text">
                            </div>
                        </div>


                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" id="upload" lay-filter="component-form-element" lay-submit>立即提交
                            </button>
                            <button class="layui-btn  layui-btn-primary" id="load">重置</button>
                            <button class="layui-btn  layui-btn-primary" id="showPage">修改密码</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>

<script type="text/javascript">
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#birthday' //指定元素
        });
    });
    window.onload = function () {
        check_load();
    }

    function check_upload() {

        var member = {
            major: $("input[id='class']").val(),
            phone: $("input[id='phone']").val(),
            qq: $("input[id='QQ']").val(),
            weChat: $("input[id='WeChat']").val(),
            email: $("input[id='email']").val(),
            birthday: $("input[id='birthday']").val(),
            address: $("input[id='address']").val()

        };
        $.ajax({

            type: 'POST',
            url: 'updateMyInfo',
            async: true,
            traditional: true,
            data: JSON.stringify(member),
            dataType: 'Text',
            contentType: "application/json;charset=UTF-8",
            success: function (data) {
                layer.msg("提交成功");

            }

        });

    }

    function check_load() {

        $.ajax({

            type: 'POST',
            url: 'getMyInfo',
            async: false,
            traditional: true,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                document.getElementById("id").value = data.id;
                document.getElementById("name").value = data.name;
                document.getElementById("QQ").value = data.qq;
                document.getElementById("email").value = data.email;
                document.getElementById("WeChat").value = data.weChat;
                document.getElementById("phone").value = data.phone;
                document.getElementById("class").value = data.major;
                document.getElementById("address").value = data.address;
                document.getElementById("birthday").value = data.birthday;
            }

        });

    }

    $(function () {

        $("#upload").click(function () {

            check_upload();
            return false;
        });
        $("#load").click(function () {

            check_load();
            return false;
        })
        $("#showPage").click(function () {

            layer.open({
                type: 2,
                title: '修改密码',
                maxmin: true,
                shadeClose: true, //点击遮罩关闭层
                area: ['800px', '520px'],
                content: 'changePassword',
                end: function () {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);//关闭当前页
                    //location.reload();
                }
            })
            return false;
        })


    })
</script>


<style id="LAY_layadmin_theme">.layui-side-menu, .layadmin-pagetabs .layui-tab-title li:after, .layadmin-pagetabs .layui-tab-title li.layui-this:after, .layui-layer-admin .layui-layer-title, .layadmin-side-shrink .layui-side-menu .layui-nav > .layui-nav-item > .layui-nav-child {
    background-color: #20222A !important;
}

.layui-nav-tree .layui-this, .layui-nav-tree .layui-this > a, .layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a {
    background-color: #009688 !important;
}

.layui-layout-admin .layui-logo {
    background-color: #20222A !important;
}</style>
</body>


</html>